package main

func findMin(arr []int) int {
	left := 0
	right := len(arr) - 1
	for left < right {
		mid := left + (right-left)/2
		if arr[mid] < arr[right] {
			right = mid
		} else {
			left = mid + 1
		}
	}
	return arr[left]
}

func main() {
	println(findMin([]int{3, 4, 5, 1, 2}))
	println(findMin([]int{3, 1, 2}))
}
